﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SearchProduct.ascx.cs" Inherits="Pub_Module_SearchProduct" %>


<table border="0" cellpadding="0" cellspacing="0" class="tbl_News" style="width: 100%">
    <tr>
        <td align="center" class="td_TitileNews">
            <asp:Label ID="Label1" runat="server" Text="TÌM KIẾM SẢN PHẨM"></asp:Label></td>
    </tr>
    <tr>
        <td class="td_Content">
            <table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
                <tr>
                    <td class="PaddingLeft_Top">
                        <table border="0" cellpadding="2" cellspacing="0" width="100%" >
                            <tr>
                                <td align="center" nowrap="nowrap">
                                    <asp:TextBox ID="txtSearch" runat="server" CssClass="txt_Common"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" nowrap="nowrap">
                                    <asp:DropDownList ID="ddlTopic" runat="server" CssClass="ddl_Common" onchange="fnGetcategoryID(this.options[this.selectedIndex].value,this)" > 
                                    </asp:DropDownList></td>
                            </tr>
                            <tr>
                                <td align="right" nowrap="nowrap">
                                    <asp:DropDownList ID="ddlCatalogue" runat="server" CssClass="ddl_Common">
                                    </asp:DropDownList></td>
                            </tr>
                            <tr>
                                <td align="right" nowrap="nowrap">
                                <input type="button" value="Tìm kiếm" id="btnSearch" onclick="fnSearch()" class="btn_Common" runat="server" /></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                <td class="td_TitleBottom">
                
                </td>
                </tr>
            </table>
        </td>
    </tr>
</table>

<script language="javascript" type="text/javascript">
    function fnGetcategoryID(IDTopic,drl_ChuDe)
    {      
        Pub_Module_SearchProduct.AjaxGetcategoryID(IDTopic,CallBackGetcategoryID)
    }
    function CallBackGetcategoryID(res)
    {
        if(res!=null)
        {
            var ds=res.value;
            if(ds!=null && typeof(ds)=="object" && ds.Tables!=null)
			{	
			    var drl_TheLoai=document.getElementById("<%= ddlCatalogue.ClientID %>");
				drl_TheLoai.options.length=0;
				var len=ds.Tables[0].Rows.length;	
				var TenTL="";
				var MaTL="";
				drl_TheLoai.options[0]=new Option("--Chọn thể loại--","");
				for(var i=0;i<len;i++)
				{	
					TenTL=ds.Tables[0].Rows[i].CatName;
					MaTL=ds.Tables[0].Rows[i].CatID;						
					drl_TheLoai.options[i+1]=new Option(TenTL,MaTL);
				}	
			}	
        }
    }
    
    function fnSearch()
    {
         var txtSearch=document.getElementById("<%= txtSearch.ClientID %>");
         var sURL="http://"+window.location.host+"/Shopping/";
         var ddlTopic=document.getElementById("<%= ddlTopic.ClientID %>");
         var ddlCatalogue=document.getElementById("<%= ddlCatalogue.ClientID %>");         
         window.location.href=sURL+"Stall/Stall.aspx?Kind=search&PdName="+txtSearch.value+"&CatID="+ddlCatalogue.value+"&TopicID="+ddlTopic.value;
    }
</script>